function createdim() {

	var dimensionCount = $('select#dddimcount option:selected').val();

	if (dimensionCount > 0 && dimensionCount != null) {
		for ( var count = 0; count < dimensionCount; count++) {
			var parentId = 'divdim' + count;
			if (document.getElementById(parentId) == null) {
				var divdim = document.createElement("div");
				divdim.setAttribute('class', 'span9');
				divdim.setAttribute('id', parentId);

				// get dimenson name from dimension object
				var dimensionName;
				divdim.innerHTML = "<h5>" + dimensionName + "</h5>";
				document.getElementById('divparams').appendChild(divdim);
				var items = {
					"select" : "Select Dimension Type",
					"2" : "DIM_TIME",
					"3" : "DIM_GEO"
				};
				var dimid = "dddim" + count;
				if (document.getElementById(dimid) == null) {
					var selectElem = document.createElement("select");
					selectElem.setAttribute("id", dimid);
					selectElem.onchange = function() {
						creatdimHrchy(this);
					};

					for ( var key in items) {
						var ov = document.createElement("option");
						ov.value = key;
						ov.appendChild(document.createTextNode(items[key]));
						selectElem.appendChild(ov);
					}
				}
				document.getElementById(parentId).appendChild(selectElem);
				selectOption(dimid, 'select');
			}
		}
	}
}

function creatdimHrchy(dimId) {

	var e = document.getElementById($(dimId).attr("id"));
	var dimVal = e.options[e.selectedIndex].text;

	/*
	 * var patent = document.getElementById($(dimId.parentNode).attr("id"));
	 * alert();
	 */

	if (dimVal != null && dimVal == "DIM_TIME") {
		if (document.getElementById("divtime") == null) {
			var elem = document.createElement("div");
			elem.setAttribute("id", "divtime");
			elem.setAttribute("class", "span9");
			elem.innerHTML = "<select id='ddyear'>	\
							<option value='select' selected='selected'>Select Year</option>	\
							<option value='2013'>2013</option>	\
							<option value='2012'>2012</option>	\
							<option value='2011'>2011</option>	\
						</select> <select id='ddmonth'>	\
							<option value='select' selected='selected'>Select Month</option>	\
							<option value='1'>Jan</option>	\
							<option value='2'>Feb</option>	\
							<option value='3'>Mar</option>	\
							<option value='4'>Apr</option>	\
							<option value='4'>Apr</option>	\
							<option value='5'>May</option>	\
							<option value='6'>Jun</option>	\
							<option value='7'>Jul</option>	\
							<option value='8'>Aug</option>	\
							<option value='9'>Sep</option>	\
							<option value='10'>Oct</option>	\
							<option value='11'>Nov</option>	\
							<option value='12'>Dec</option>	\
							<option value='0'>None</option>	\
						</select>";

			document.getElementById($(dimId.parentNode).attr("id"))
					.appendChild(elem);
		}
	}

	if (dimVal != null && dimVal == "DIM_GEO") {
		if (document.getElementById("divgeo") == null) {
			var elem = document.createElement("div");
			elem.setAttribute("id", "divgeo");
			elem.setAttribute("class", "span9");
			elem.innerHTML = "<select id='ddcountry'>	\
							<option value='select' selected='selected'>Select	\
								Country</option>	\
							<option value='India'>India</option>	\
						</select> <select id='ddstate'>	\
							<option value='select' selected='selected'>Select State</option>	\
							<option value='West Bengal'>West Bengal</option>	\
						</select> <select id='ddcity' >	\
							<option value='select' selected='selected'>Select City</option>	\
							<option value='Kolkata'>Kolkata</option>	\
						</select> <select id='ddarea' >	\
							<option value='select' selected='selected'>Select Area</option>	\
							<option value='Saltlake'>Saltlake</option>	\
							<option value='Rajarhat'>Rajarhat</option>	\
							<option value='Behala'>Behala</option>		\
							<option value='NewAlipur'>NewAlipur</option>	\
							<option value='Golpark'>Golpark</option>	\
							<option value='All'>All</option>		\
						</select> <select id='ddsubarea' >			\
							<option value='select' selected='selected'>Select	\
								Sub-Station</option>	\
							<option value='SS01'>SS01</option>	\
							<option value='SS02'>SS02</option>	\
							<option value='SS03'>SS03</option>	\
							<option value='SS04'>SS04</option>	\
							<option value='SS05'>SS05</option>	\
							<option value='SS06'>SS06</option>	\
							<option value='All'>All</option>	\
						</select> <select id='ddcusttype' >	\        							<option value='select' selected='selected'>Select Customer Type</option>	\
							<option value='Commercial'>Commercial</option>	\
							<option value='Domestic'>Domestic</option>	\
							<option value='All'>All</option>	\
						</select>";

			document.getElementById($(dimId.parentNode).attr("id"))
					.appendChild(elem);
		}
	}

}
